package com.ruoyi.admin.mapper;


import com.ruoyi.admin.domain.Alarm;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.Mapping;

import java.util.Date;
import java.util.List;

@Mapper
public interface AlarmMapper {


    @Select("select *,alarm_time as alarmTime from alarm where alarm_time>=CURDATE() and alarm_time<=NOW() order by alarmTime desc")
    public List<Alarm>  getAlarmInfo();


    @Insert("INSERT INTO alarm(sensor_id, title, content, alarm_time) VALUES(#{sensorId}, #{title}, #{content}, #{alarmTime})")
    void insertAlarm(Alarm alarm);



    @Insert({
            "<script>",
            "INSERT INTO alarm(sensor_id, title, content, alarm_time) VALUES ",
            "<foreach collection='list' item='alarm' separator=','>",
            "(#{alarm.sensorId}, #{alarm.title}, #{alarm.content}, #{alarm.alarmTime})",
            "</foreach>",
            "</script>"
    })
    void insertAlarmsAsync(List<Alarm> alarms);
}
